import { ref } from 'vue'
import { listTaskDict } from '@/apis'
import type { LabelValueState } from '@/types/global'

/** 用户名模块 */
export function useTaskName(options?: { onSuccess?: () => void }) {
  const loading = ref(false)
  const taskNameList = ref<LabelValueState[]>([])
  const getTaskNameList = async () => {
    try {
      loading.value = true
      const res = await listTaskDict()
      taskNameList.value = res.data
      options?.onSuccess && options.onSuccess()
    } finally {
      loading.value = false
    }
  }
  return { taskNameList, getTaskNameList, loading }
}
